// xstddef internal header
#pragma once
#ifndef _XSTDDEF_
#define _XSTDDEF_
#ifndef RC_INVOKED
#include <cstddef>
#include <cstdlib>

#include <initializer_list>

#include <xtr1common>

 #pragma pack(push,_CRT_PACKING)
 #pragma warning(push,_STL_WARNING_LEVEL)
 #pragma warning(disable: _STL_DISABLED_WARNINGS)
 #pragma push_macro("new")
 #undef new

_STD_BEGIN
		// EXCEPTION MACROS
 #ifndef _THROWS
 #define _THROWS(x)
 #endif /* _THROWS */

 #if _HAS_EXCEPTIONS
 #define _TRY_BEGIN	try {
 #define _CATCH(x)	} catch (x) {
 #define _CATCH_ALL	} catch (...) {
 #define _CATCH_END	}

 #define _RAISE(x)	throw x
 #define _RERAISE	throw

  #define _THROW0()		noexcept

  #if defined(MRTDLL) && defined(_M_CEE) && !defined(_M_CEE_PURE) \
	&& defined(_CRTBLD)
   #define _THROW(x, y)	_should_not_throw()	/* force compile error */

   #if defined(_DEBUG)
    #define _THROW_NCEE(x, y)	\
		_invoke_watson(_CRT_WIDE(#x), __FUNCTIONW__, __FILEW__, __LINE__, 0)

   #else /* defined(_DEBUG) */
    #define _THROW_NCEE(x, y)	\
		_invoke_watson(0, 0, 0, 0, 0)
   #endif /* defined(_DEBUG) */

  #else /* defined(MRTDLL) etc. */
   #define _THROW(x, y)			throw x(y)
   #define _THROW_NCEE(x, y)	throw x(y)
  #endif /* defined(MRTDLL) etc. */

 #else /* _HAS_EXCEPTIONS */
 #define _TRY_BEGIN	{ if (1) {
 #define _CATCH(x)	} else if (0) {
 #define _CATCH_ALL	} else if (0) {
 #define _CATCH_END	} }

 #if defined(_DEBUG)
  #define _RAISE(x)	\
	_invoke_watson(_CRT_WIDE(#x), __FUNCTIONW__, __FILEW__, __LINE__, 0)

 #else /* defined(_DEBUG) */
  #define _RAISE(x)	\
	_invoke_watson(0, 0, 0, 0, 0)
 #endif /* defined(_DEBUG) */

 #define _RERAISE

 #define _THROW0()
 #define _THROW(x, y)		x(y)._Raise()
 #define _THROW_NCEE(x, y)	x(y)._Raise()
 #endif /* _HAS_EXCEPTIONS */

		// MISCELLANEOUS MACROS
#define _EMPTY_ARGUMENT		/* for empty macro argument */

		// BITMASK MACROS
 #define _BITMASK(Enum, Ty)	typedef Enum Ty

 #define _BITMASK_OPS(Ty) \
inline Ty& operator&=(Ty& _Left, Ty _Right) \
	{	/* return _Left &= _Right */ \
	_Left = (Ty)((int)_Left & (int)_Right); return (_Left); \
	} \
\
inline Ty& operator|=(Ty& _Left, Ty _Right) \
	{	/* return _Left |= _Right */ \
	_Left = (Ty)((int)_Left | (int)_Right); return (_Left); \
	} \
\
inline Ty& operator^=(Ty& _Left, Ty _Right) \
	{	/* return _Left ^= _Right */ \
	_Left = (Ty)((int)_Left ^ (int)_Right); return (_Left); \
	} \
\
inline constexpr Ty operator&(Ty _Left, Ty _Right) \
	{	/* return _Left & _Right */ \
	return ((Ty)((int)_Left & (int)_Right)); \
	} \
\
inline constexpr Ty operator|(Ty _Left, Ty _Right) \
	{	/* return _Left | _Right */ \
	return ((Ty)((int)_Left | (int)_Right)); \
	} \
\
inline constexpr Ty operator^(Ty _Left, Ty _Right) \
	{	/* return _Left ^ _Right */ \
	return ((Ty)((int)_Left ^ (int)_Right)); \
	} \
\
inline constexpr Ty operator~(Ty _Left) \
	{	/* return ~_Left */ \
	return ((Ty)~(int)_Left); \
	}

 #define _IOS_BITMASK(Enum, Ty)	typedef int Ty
 #define _IOS_BITMASK_OPS(Ty)

		// TYPE DEFINITIONS

template<bool,
	class _Ty1,
	class _Ty2>
	struct _If
	{	// type is _Ty2 for assumed false
	typedef _Ty2 type;
	};

template<class _Ty1,
	class _Ty2>
	struct _If<true, _Ty1, _Ty2>
	{	// type is _Ty1 for assumed true
	typedef _Ty1 type;
	};

template<class _Ty>
	struct _Always_false
	{	// false value attached to a dependent name (for static_assert)
	static constexpr bool value = false;
	};

		// FUNCTIONAL STUFF (from <functional>)

 #if _HAS_AUTO_PTR_ETC
		// TEMPLATE STRUCT unary_function
template<class _Arg,
	class _Result>
	struct unary_function
	{	// base class for unary functions
	typedef _Arg argument_type;
	typedef _Result result_type;
	};

		// TEMPLATE STRUCT binary_function
template<class _Arg1,
	class _Arg2,
	class _Result>
	struct binary_function
	{	// base class for binary functions
	typedef _Arg1 first_argument_type;
	typedef _Arg2 second_argument_type;
	typedef _Result result_type;
	};
 #endif /* _HAS_AUTO_PTR_ETC */

		// TEMPLATE STRUCT plus
template<class _Ty = void>
	struct plus
	{	// functor for operator+
	typedef _Ty first_argument_type;
	typedef _Ty second_argument_type;
	typedef _Ty result_type;

	constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator+ to operands
		return (_Left + _Right);
		}
	};

		// TEMPLATE STRUCT minus
template<class _Ty = void>
	struct minus
	{	// functor for operator-
	typedef _Ty first_argument_type;
	typedef _Ty second_argument_type;
	typedef _Ty result_type;

	constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator- to operands
		return (_Left - _Right);
		}
	};

		// TEMPLATE STRUCT multiplies
template<class _Ty = void>
	struct multiplies
	{	// functor for operator*
	typedef _Ty first_argument_type;
	typedef _Ty second_argument_type;
	typedef _Ty result_type;

	constexpr _Ty operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator* to operands
		return (_Left * _Right);
		}
	};

		// TEMPLATE STRUCT equal_to
template<class _Ty = void>
	struct equal_to
	{	// functor for operator==
	typedef _Ty first_argument_type;
	typedef _Ty second_argument_type;
	typedef bool result_type;

	constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator== to operands
		return (_Left == _Right);
		}
	};

		// TEMPLATE STRUCT less
template<class _Ty = void>
	struct less
	{	// functor for operator<
	typedef _Ty first_argument_type;
	typedef _Ty second_argument_type;
	typedef bool result_type;

	constexpr bool operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator< to operands
		return (_Left < _Right);
		}
	};

		// TEMPLATE STRUCT SPECIALIZATION plus
template<>
	struct plus<void>
	{	// transparent functor for operator+
	typedef int is_transparent;

	template<class _Ty1,
		class _Ty2>
		constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
		-> decltype(static_cast<_Ty1&&>(_Left)
			+ static_cast<_Ty2&&>(_Right))
		{	// transparently apply operator+ to operands
		return (static_cast<_Ty1&&>(_Left)
			+ static_cast<_Ty2&&>(_Right));
		}
	};

		// TEMPLATE STRUCT SPECIALIZATION minus
template<>
	struct minus<void>
	{	// transparent functor for operator-
	typedef int is_transparent;

	template<class _Ty1,
		class _Ty2>
		constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
		-> decltype(static_cast<_Ty1&&>(_Left)
			- static_cast<_Ty2&&>(_Right))
		{	// transparently apply operator- to operands
		return (static_cast<_Ty1&&>(_Left)
			- static_cast<_Ty2&&>(_Right));
		}
	};

		// TEMPLATE STRUCT SPECIALIZATION multiplies
template<>
	struct multiplies<void>
	{	// transparent functor for operator*
	typedef int is_transparent;

	template<class _Ty1,
		class _Ty2>
		constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
		-> decltype(static_cast<_Ty1&&>(_Left)
			* static_cast<_Ty2&&>(_Right))
		{	// transparently apply operator* to operands
		return (static_cast<_Ty1&&>(_Left)
			* static_cast<_Ty2&&>(_Right));
		}
	};

		// TEMPLATE STRUCT SPECIALIZATION equal_to
template<>
	struct equal_to<void>
	{	// transparent functor for operator==
	typedef int is_transparent;

	template<class _Ty1,
		class _Ty2>
		constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
		-> decltype(static_cast<_Ty1&&>(_Left)
			== static_cast<_Ty2&&>(_Right))
		{	// transparently apply operator== to operands
		return (static_cast<_Ty1&&>(_Left)
			== static_cast<_Ty2&&>(_Right));
		}
	};

		// TEMPLATE STRUCT SPECIALIZATION less
template<>
	struct less<void>
	{	// transparent functor for operator<
	typedef int is_transparent;

	template<class _Ty1,
		class _Ty2>
		constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
		-> decltype(static_cast<_Ty1&&>(_Left)
			< static_cast<_Ty2&&>(_Right))
		{	// transparently apply operator< to operands
		return (static_cast<_Ty1&&>(_Left)
			< static_cast<_Ty2&&>(_Right));
		}
	};


_STD_END

#ifndef _HASH_SEQ_DEFINED
#define _HASH_SEQ_DEFINED
_STD_BEGIN
	// FUNCTION _Hash_seq
inline size_t _Hash_seq(const unsigned char *_First, size_t _Count)
	{	// FNV-1a hash function for bytes in [_First, _First + _Count)
 #if defined(_WIN64)
	static_assert(sizeof(size_t) == 8, "This code is for 64-bit size_t.");
	const size_t _FNV_offset_basis = 14695981039346656037ULL;
	const size_t _FNV_prime = 1099511628211ULL;

 #else /* defined(_WIN64) */
	static_assert(sizeof(size_t) == 4, "This code is for 32-bit size_t.");
	const size_t _FNV_offset_basis = 2166136261U;
	const size_t _FNV_prime = 16777619U;
 #endif /* defined(_WIN64) */

	size_t _Val = _FNV_offset_basis;
	for (size_t _Next = 0; _Next < _Count; ++_Next)
		{	// fold in another byte
		_Val ^= (size_t)_First[_Next];
		_Val *= _FNV_prime;
		}
	return (_Val);
	}

	// TEMPLATE STRUCT _Bitwise_hash
template<class _Kty>
	struct _Bitwise_hash
	{	// hash functor for plain old data
	typedef _Kty argument_type;
	typedef size_t result_type;

	size_t operator()(const _Kty& _Keyval) const
		{	// hash _Keyval to size_t value by pseudorandomizing transform
		return (_Hash_seq((const unsigned char *)&_Keyval, sizeof (_Kty)));
		}
	};

	// TEMPLATE STRUCT hash
template<class _Kty>
	struct hash
		: public _Bitwise_hash<_Kty>
	{	// hash functor for enums
	static constexpr bool _Value = __is_enum(_Kty);
	static_assert(_Value,
		"The C++ Standard doesn't provide a hash for this type.");
	};
template<>
	struct hash<bool>
		: public _Bitwise_hash<bool>
	{	// hash functor for bool
	};

template<>
	struct hash<char>
		: public _Bitwise_hash<char>
	{	// hash functor for char
	};

template<>
	struct hash<signed char>
		: public _Bitwise_hash<signed char>
	{	// hash functor for signed char
	};

template<>
	struct hash<unsigned char>
		: public _Bitwise_hash<unsigned char>
	{	// hash functor for unsigned char
	};

template<>
	struct hash<char16_t>
		: public _Bitwise_hash<char16_t>
	{	// hash functor for char16_t
	};

template<>
	struct hash<char32_t>
		: public _Bitwise_hash<char32_t>
	{	// hash functor for char32_t
	};

 #ifdef _NATIVE_WCHAR_T_DEFINED
template<>
	struct hash<wchar_t>
		: public _Bitwise_hash<wchar_t>
	{	// hash functor for wchar_t
	};
 #endif /* _NATIVE_WCHAR_T_DEFINED */

template<>
	struct hash<short>
		: public _Bitwise_hash<short>
	{	// hash functor for short
	};

template<>
	struct hash<unsigned short>
		: public _Bitwise_hash<unsigned short>
	{	// hash functor for unsigned short
	};

template<>
	struct hash<int>
		: public _Bitwise_hash<int>
	{	// hash functor for int
	};

template<>
	struct hash<unsigned int>
		: public _Bitwise_hash<unsigned int>
	{	// hash functor for unsigned int
	};

template<>
	struct hash<long>
		: public _Bitwise_hash<long>
	{	// hash functor for long
	};

template<>
	struct hash<unsigned long>
		: public _Bitwise_hash<unsigned long>
	{	// hash functor for unsigned long
	};

template<>
	struct hash<long long>
		: public _Bitwise_hash<long long>
	{	// hash functor for long long
	};

template<>
	struct hash<unsigned long long>
		: public _Bitwise_hash<unsigned long long>
	{	// hash functor for unsigned long long
	};

template<>
	struct hash<float>
		: public _Bitwise_hash<float>
	{	// hash functor for float
	typedef float _Kty;
	typedef _Bitwise_hash<_Kty> _Mybase;

	size_t operator()(const _Kty& _Keyval) const
		{	// hash _Keyval to size_t value by pseudorandomizing transform
		return (_Mybase::operator()(
			_Keyval == 0 ? 0 : _Keyval));	// map -0 to 0
		}
	};

template<>
	struct hash<double>
		: public _Bitwise_hash<double>
	{	// hash functor for double
	typedef double _Kty;
	typedef _Bitwise_hash<_Kty> _Mybase;

	size_t operator()(const _Kty& _Keyval) const
		{	// hash _Keyval to size_t value by pseudorandomizing transform
		return (_Mybase::operator()(
			_Keyval == 0 ? 0 : _Keyval));	// map -0 to 0
		}
	};

template<>
	struct hash<long double>
		: public _Bitwise_hash<long double>
	{	// hash functor for long double
	typedef long double _Kty;
	typedef _Bitwise_hash<_Kty> _Mybase;

	size_t operator()(const _Kty& _Keyval) const
		{	// hash _Keyval to size_t value by pseudorandomizing transform
		return (_Mybase::operator()(
			_Keyval == 0 ? 0 : _Keyval));	// map -0 to 0
		}
	};

template<class _Ty>
	struct hash<_Ty *>
		: public _Bitwise_hash<_Ty *>
	{	// hash functor for _Ty *
	};
_STD_END
#endif /* _HASH_SEQ_DEFINED */

#if _HAS_TR1_NAMESPACE
_STD_BEGIN
namespace tr1 {	// TR1 ADDITIONS
using _STD hash;
}	// namespace tr1
_STD_END
#endif /* _HAS_TR1_NAMESPACE */

#define _EMIT_CDECL(FUNC, OPT1, OPT2) \
	FUNC(__cdecl, OPT1, OPT2)

 #ifdef _M_CEE
#define _EMIT_CLRCALL(FUNC, OPT1, OPT2) \
	FUNC(__clrcall, OPT1, OPT2)

 #else /* _M_CEE */
#define _EMIT_CLRCALL(FUNC, OPT1, OPT2)
 #endif /* _M_CEE */

 #if defined(_M_IX86) && !defined(_M_CEE)
#define _EMIT_FASTCALL(FUNC, OPT1, OPT2) \
	FUNC(__fastcall, OPT1, OPT2)

 #else /* defined(_M_IX86) && !defined(_M_CEE) */
#define _EMIT_FASTCALL(FUNC, OPT1, OPT2)
 #endif /* defined(_M_IX86) && !defined(_M_CEE) */

 #ifdef _M_IX86
#define _EMIT_STDCALL(FUNC, OPT1, OPT2) \
	FUNC(__stdcall, OPT1, OPT2)
#define _EMIT_THISCALL(FUNC, OPT1, OPT2) \
	FUNC(__thiscall, OPT1, OPT2)

 #else /* _M_IX86 */
#define _EMIT_STDCALL(FUNC, OPT1, OPT2)
#define _EMIT_THISCALL(FUNC, OPT1, OPT2)
 #endif /* _M_IX86 */

 #if ((defined(_M_IX86) && _M_IX86_FP >= 2) \
	|| defined(_M_X64)) && !defined(_M_CEE)
#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2) \
	FUNC(__vectorcall, OPT1, OPT2)

 #else /* defined(_M_IX86) && _M_IX86_FP >= 2 etc. */
#define _EMIT_VECTORCALL(FUNC, OPT1, OPT2)
 #endif /* defined(_M_IX86) && _M_IX86_FP >= 2 etc. */

#define _NON_MEMBER_CALL(FUNC, CV_REF_OPT) \
	_EMIT_CDECL(FUNC, CV_REF_OPT, ) \
	_EMIT_CLRCALL(FUNC, CV_REF_OPT, ) \
	_EMIT_FASTCALL(FUNC, CV_REF_OPT, ) \
	_EMIT_STDCALL(FUNC, CV_REF_OPT, ) \
	_EMIT_VECTORCALL(FUNC, CV_REF_OPT, )

#define _NON_MEMBER_CALL_CV(FUNC, REF_OPT) \
	_NON_MEMBER_CALL(FUNC, REF_OPT) \
	_NON_MEMBER_CALL(FUNC, const REF_OPT) \
	_NON_MEMBER_CALL(FUNC, volatile REF_OPT) \
	_NON_MEMBER_CALL(FUNC, const volatile REF_OPT)

#define _NON_MEMBER_CALL_CV_REF(FUNC) \
	_NON_MEMBER_CALL_CV(FUNC, ) \
	_NON_MEMBER_CALL_CV(FUNC, &) \
	_NON_MEMBER_CALL_CV(FUNC, &&)

#define _MEMBER_CALL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_CDECL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_CLRCALL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_FASTCALL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_STDCALL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_THISCALL(FUNC, CV_OPT, REF_OPT) \
	_EMIT_VECTORCALL(FUNC, CV_OPT, REF_OPT)

#define _MEMBER_CALL_CV(FUNC, REF_OPT) \
	_MEMBER_CALL(FUNC, , REF_OPT) \
	_MEMBER_CALL(FUNC, const, REF_OPT) \
	_MEMBER_CALL(FUNC, volatile, REF_OPT) \
	_MEMBER_CALL(FUNC, const volatile, REF_OPT)

#define _MEMBER_CALL_CV_REF(FUNC) \
	_MEMBER_CALL_CV(FUNC, ) \
	_MEMBER_CALL_CV(FUNC, &) \
	_MEMBER_CALL_CV(FUNC, &&)

#define _CLASS_DEFINE_CONST(CLASS) \
	CLASS(_EMPTY_ARGUMENT) \
	CLASS(const)

#define _CLASS_DEFINE_CV(CLASS) \
	CLASS(_EMPTY_ARGUMENT) \
	CLASS(const) \
	CLASS(volatile) \
	CLASS(const volatile)

#define _CLASS_DEFINE_CV_REF(CLASS) \
	CLASS(_EMPTY_ARGUMENT) \
	CLASS(const) \
	CLASS(volatile) \
	CLASS(const volatile) \
	CLASS(&) \
	CLASS(const &) \
	CLASS(volatile &) \
	CLASS(const volatile &) \
	CLASS(&&) \
	CLASS(const &&) \
	CLASS(volatile &&) \
	CLASS(const volatile &&)


_STD_BEGIN
		// TEMPLATE FUNCTION addressof
template<class _Ty> inline
	constexpr _Ty *addressof(_Ty& _Val) _NOEXCEPT
	{	// return address of _Val
	return (__builtin_addressof(_Val));
	}

		// FUNCTION TEMPLATE _Unfancy
template<class _Ptrty> inline
	auto _Unfancy(_Ptrty _Ptr)
	{	// converts from a fancy pointer to a plain pointer
	return (_STD addressof(*_Ptr));
	}

template<class _Ty> inline
	_Ty * _Unfancy(_Ty * _Ptr)
	{	// do nothing for plain pointers
	return (_Ptr);
	}

_STD_END
 #pragma pop_macro("new")
 #pragma warning(pop)
 #pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _XSTDDEF_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V6.50:0009 */
